home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / worldsrc.zip / PARSER.C < prev    next >
C/C++ Source or Header  |  1992-08-13  |  19KB  |  873 lines

  1. #define EXTERN extern
  2.  
  3. #include "parame.inc"
  4. #include "variab.h"
  5. #include "arrays.h"
  6. #include "vocab.inc"
  7. #include "verbtb.inc"
  8.  
  9. /* World C Version 1.00 copyright 1987 J.D.McDonald 
  10.    Use as you like for non-commercial purposes, but please
  11.    leave this note, and document any changes you make as yours */
  12.  
  13. /* No apologies for all the goto's. If you can get rid of them, well,
  14.    I guess some persons are just naturally masochists */
  15.  
  16. static int      typlst[4] = {VRBMIN, ADJMIN, NUNMIN, PRPMIN};
  17. static int      index[5], indx;
  18.  
  19. scan()
  20. /*
  21.  * this function scans the input line for gross syntax errors it also expands
  22.  * special direction commands such as "ne" into their full form. it also
  23.  * works on adverbs, removes such expressions as "ask frog," etc. finally it
  24.  * puts the word numbers and types in the wrdnum and wrdtyp arrays the input
  25.  * is inbuf ,the output is wrdnum,wrdtyp,actor,adverb 
  26.  *
  27.  */
  28. {
  29.     int             result, offlg, askx, lptr0, wptr, i, lxx, errno;
  30.  
  31.     result = 0;
  32.     offlg = 0;
  33.     chgact = 0;
  34.     askx = 0;
  35.  
  36. lab5:
  37.     adverb = 0;
  38.     for (i = 0; i < 30; i++) {
  39.     wrdnum[i] = 0;
  40.     wrdtyp[i] = 0;
  41.     }
  42.     /*
  43.      * wordtyp is -1 for a period,-2 comma 1 for adverb,2 verb,3 adjective,4
  44.      * noun,5 preposition numbers are type 4,and wrdnum=number+10000 
  45.      */
  46.  
  47.     wptr = 0;
  48. lab10:
  49.     lptr0 = lptr;
  50.     wscan();
  51.     /*
  52.      * on return from wscan punct contains: 0 for a word 1 for a period 2 for
  53.      * a comma 3 for a number 4 if an illegal character 5 if a number follows
  54.      * a letter directly 6 if a letter follows a number directly 
  55.      */
  56.  
  57.     if (punct == 1)
  58.     return (result);
  59.     else if (punct == 4)
  60.     goto lab9000;
  61.     else if (punct == 2)
  62.     goto lab9010;
  63.     else if (punct == 3)
  64.     goto lab9019;
  65.     else if (punct == 5)
  66.     goto lab9020;
  67.     else if (punct == 6)
  68.     goto lab9140;
  69.     else;
  70.     /* it's a real word, so find out what it is */
  71.  
  72.     find(VOCMAX);
  73.  
  74.     /* discard buzzword  */
  75.  
  76.     if (indx > 0 && indx <= BUZMAX)
  77.     goto lab10;
  78.     if (indx == 0)
  79.     goto lab9040;
  80.  
  81.     if ((indx >= NORTH && indx <= NORTHW) || indx == UP
  82.     || indx == DOWN) {
  83.     /* yes,it's a special word  */
  84.  
  85.     lptr0 = lptr;
  86.     wscan();
  87.     /* check if it's all that's on the line  */
  88.  
  89.     if (punct != 1)
  90.         goto lab9030;
  91.     /* expand a direction word into full form */
  92.  
  93.     wrdtyp[1] = 4;
  94.     wrdnum[1] = indx;
  95.     wrdnum[0] = GO;
  96.     wrdtyp[0] = 2;
  97.     wrdtyp[2] = -1;
  98.     goto lab9999;
  99.     }
  100.     if (index[0] != 0) {
  101.     if (adverb != 0)
  102.         goto lab9070;
  103.     /* adverbs are removed from the wrdtyp list and handled separately */
  104.  
  105.     adverb = index[0];
  106.     if (adverb != WHERE && adverb != WHAT)
  107.         goto lab10;
  108.     if (actor == 1 || askx != ASK)
  109.         goto lab9130;
  110.     goto lab10;
  111.     }
  112.     if (index[1] == 0)
  113.     goto lab9050;
  114.     wrdtyp[wptr] = 2;
  115.     wrdnum[wptr] = index[1];
  116.     /*
  117.      * we've found the verb check for legal question  
  118.      */
  119.  
  120.     if ((adverb == WHAT || adverb == WHERE) - (wrdnum[0] == IS))
  121.     goto lab9130;
  122.     if (wrdnum[0] == YELL) {
  123.     /* the player is told to use "ask" or "tell" */
  124.  
  125. lab131:
  126.     wscan();
  127.     if (punct != 1)
  128.         goto lab131;
  129.     wrdtyp[0] = 2;
  130.     wrdnum[0] = YELL;
  131.     result = 1;
  132.     return (result);
  133.     }
  134.     if (wrdnum[0] < SHIT)
  135.     goto lab200;
  136.     /*
  137.      * special handling for words which take no objects or modifiers they
  138.      * should be alone on a line. they are verbs >= shit  
  139.      */
  140.  
  141.     lptr0 = lptr;
  142.     wscan();
  143.     {
  144.     if (punct == 1)
  145.         goto lab9998;
  146.     else if (punct == 5)
  147.         goto lab9120;
  148.     else
  149.         goto lab9150;
  150.     }
  151.     /* inner loop for all words after verb  */
  152.  
  153. lab200:
  154.     wptr += 1;
  155.     if (wptr > 27)
  156.     goto lab9180;
  157.  
  158. lab201:
  159.     lptr0 = lptr;
  160.     wscan();
  161.     if (punct != 0)
  162.     goto lab210;
  163.     find(BUZMAX);
  164.     /* special code for "noun1 of noun2" construct  */
  165.  
  166.     if (indx == 4 && wrdtyp[wptr - 1] == 4)
  167.     offlg = 1;
  168.     if (indx != 0)
  169.     goto lab201;
  170.     goto lab215;
  171. lab210:
  172.     if (punct == 4)
  173.     goto lab9000;
  174.     if (punct == 5)
  175.     goto lab9020;
  176.     if (punct == 6)
  177.     goto lab9140;
  178.     if (punct != 2)
  179.     goto lab215;
  180.     if (wrdtyp[wptr - 1] != 4)
  181.     goto lab9010;
  182.     wrdtyp[wptr] = -2;
  183.     goto lab200;
  184.  
  185. lab215:
  186.     if (wrdtyp[wptr - 1] != 2 || (wrdnum[wptr - 1] != ASK
  187.                   && wrdnum[wptr - 1] != TELL))
  188.     goto lab220;
  189.     if (punct == 3)
  190.     goto lab9019;
  191.     if (punct != 0)
  192.     goto lab9010;
  193.     if (actor != 1)
  194.     goto lab9100;
  195.     /*
  196.      * this code is to set up addressing a second "person" the phrases "ask
  197.      * frog" or "tell frog" etc are discarded and the variable "actor" tells
  198.      * us who is addressed  
  199.      */
  200.  
  201.     askx = wrdnum[wptr - 1];
  202.     find(VOCMAX);
  203.     if ((index[3] != 0) &&
  204.     (index[3] < ROBOT || index[3] > FERRET))
  205.     goto lab9090;
  206.     if (index[3] == 0)
  207.     goto lab9160;
  208.     actor = index[3];
  209.     lptr0 = lptr;
  210.     chgact = 1;
  211.     wscan();
  212.     if (punct != 2)
  213.     goto lab9110;
  214.     goto lab5;
  215.     /* code for numbers inputted in a statement */
  216.  
  217. lab220:
  218.     if (punct != 3)
  219.     goto lab240;
  220.     wrdtyp[wptr] = 4;
  221.     wrdnum[wptr] = three[0] + 10000;
  222.     goto lab200;
  223.     /* all regular words go here */
  224.  
  225. lab240:
  226.  
  227.     if (punct != 1)
  228.     goto lab250;
  229.     wrdtyp[wptr] = -1;
  230.     goto lab9999;
  231. lab250:
  232.     find(VOCMAX);
  233.     if (indx == 0)
  234.     goto lab9040;
  235.     /* special code for "of" handler */
  236.  
  237.     if (offlg) {
  238.     offlg = 0;
  239.     if (index[3] != 0 && wrdtyp[wptr - 2] != 3) {
  240.         /* exchange two nouns and tell parser the first is an adjective */
  241.  
  242.         wrdtyp[wptr] = wrdtyp[wptr - 1];
  243.         wrdnum[wptr] = wrdnum[wptr - 1];
  244.         wrdtyp[wptr - 1] = 3;
  245.         wrdnum[wptr - 1] = index[3];
  246.         if (wrdnum[wptr] == PHOTOG && wrdnum[wptr - 1] == FERRET) {
  247.         wrdnum[wptr - 1] = FAMILY;
  248.             }
  249.             goto lab200;
  250.         }
  251.     else
  252.             goto lab9200;
  253.     }
  254.     if (indx != AND)
  255.     goto lab270;
  256.     if (wrdtyp[wptr - 1] == -2)
  257.     goto lab201;
  258.     if (wrdtyp[wptr - 1] != 4)
  259.     goto lab9120;
  260.     wrdtyp[wptr] = -2;
  261.     goto lab200;
  262. lab270:
  263.     if (index[1] != 0 && index[0] == 0 && index[2] == 0
  264.     && index[3] == 0 && index[4] == 0)
  265.     goto lab9080;
  266.     if (index[0] == 0)
  267.     goto lab280;
  268.     if (adverb != 0)
  269.     goto lab9070;
  270.     adverb = indx;
  271.     if (adverb == WHERE || adverb == WHAT)
  272.     goto lab9130;
  273.     goto lab201;
  274.     /* at this point the word must be an adjectine, noun or preposition */
  275.  
  276. lab280:
  277.     if (wrdtyp[wptr - 1] == 3 && index[2] != 0)
  278.     goto lab9170;
  279.     if (index[2] != 0) {
  280.     wrdtyp[wptr] = 3;
  281.     wrdnum[wptr] = index[2];
  282.     } else if (index[3] != 0) {
  283.     wrdtyp[wptr] = 4;
  284.     wrdnum[wptr] = index[3];
  285.     } else {
  286.     wrdtyp[wptr] = 5;
  287.     wrdnum[wptr] = index[4];
  288.     }
  289.     if ((wrdtyp[wptr] == 4 && wrdtyp[wptr - 1] == 3) &&
  290.     wrdnum[wptr] < SAPPHI)
  291.     goto lab9190;
  292.     goto lab200;
  293.  
  294.  
  295.     /***********       error processing  */
  296.  
  297. lab9000:
  298.     lxx = lptr;
  299.     errno = 1;
  300.     goto lab9900;
  301. lab9010:
  302.     lxx = lptr;
  303.     errno = 2;
  304.     goto lab9900;
  305. lab9019:
  306.     lptr -= 1;
  307. lab9020:
  308.     lptr += 1;
  309.     lxx = lptr;
  310.     errno = 3;
  311.     goto lab9900;
  312. lab9030:
  313.     lxx = lptr;
  314.     errno = 4;
  315.     goto lab9900;
  316. lab9040:
  317.     lxx = lptr;
  318.     errno = 5;
  319.     goto lab9900;
  320. lab9050:
  321.     lxx = lptr;
  322.     errno = 6;
  323.     goto lab9900;
  324. lab9070:
  325.     lxx = lptr;
  326.     errno = 8;
  327.     goto lab9900;
  328. lab9080:
  329.     lxx = lptr;
  330.     errno = 9;
  331.     goto lab9900;
  332. lab9090:
  333.     lxx = 0;
  334.     errno = 10;
  335.     goto lab9900;
  336. lab9100:
  337.     lxx = 0;
  338.     errno = 11;
  339.     goto lab9900;
  340. lab9110:
  341.     lxx = lptr0 + 1;
  342.     errno = 12;
  343.     goto lab9900;
  344. lab9120:
  345.     lxx = lptr;
  346.     errno = 13;
  347.     goto lab9900;
  348. lab9130:
  349.     lxx = 0;
  350.     errno = 14;
  351.     goto lab9900;
  352. lab9140:
  353.     lxx = lptr;
  354.     errno = 15;
  355.     goto lab9900;
  356. lab9150:
  357.     lxx = lptr0;
  358.     errno = 16;
  359.     goto lab9900;
  360. lab9160:
  361.     lxx = 0;
  362.     errno = 17;
  363.     goto lab9900;
  364. lab9170:
  365.     lxx = lptr;
  366.     errno = 18;
  367.     goto lab9900;
  368. lab9180:
  369.     lxx = 0;
  370.     errno = 25;
  371.     goto lab9900;
  372. lab9190:
  373.     lxx = lptr;
  374.     errno = 107;
  375.     goto lab9900;
  376. lab9200:
  377.     lxx = lptr;
  378.     errno = 112;
  379. lab9900:
  380.     carerr(lxx, errno);
  381.     return (result);
  382. lab9998:
  383.     wrdtyp[1] = -1;
  384. lab9999:
  385.     if ((askx == TELL && (adverb == WHERE || adverb == WHAT))
  386.     || (askx == ASK && (adverb != WHERE && adverb != WHAT)))
  387.     goto lab9130;
  388.     if (adverb == WHERE || adverb == WHAT)
  389.     dotflg = 1;
  390.     result = 1;
  391.     return (result);
  392.  
  393. }
  394.  
  395. wscan()
  396. /*
  397.  * this routine reads the input ascii code and scans for punctuation or
  398.  * numbers and then converts the first 9 letters of a word to three integer*2
  399.  * words of radix 32 form  
  400.  */
  401.  
  402. {
  403.     char            m;
  404.     static int      pow32[] = {1, 32, 1024, 32768};
  405.     int             plcpnt, wpnt, kchar;
  406.  
  407.     if (dotflg) {
  408.     actor = 1;
  409.     dotflg = 0;
  410.     }
  411.     plcpnt = 1;
  412.     punct = 0;
  413.     wpnt = 1;
  414.     three[0] = 0;
  415.     three[1] = 0;
  416.     three[2] = 0;
  417.     while (inbuf[lptr] == ' ')
  418.     lptr++;
  419.     /*
  420.      * punct =1 is period, 2 is comma, 3 is number,4 is illegal character and
  421.      * 5 means a number directly follows a word 6 means letter follows a
  422.      * number 
  423.      */
  424.  
  425.     if (inbuf[lptr] == '.' || inbuf[lptr] == '?') {
  426.     dotflg = 1;
  427.     punct = 1;
  428.     lptr += 1;
  429.     return (0);
  430.     }
  431.     if (inbuf[lptr] == ',') {
  432.     punct = 2;
  433.     lptr += 1;
  434.     return (0);
  435.     }
  436.     while (inbuf[lptr] >= '0' && inbuf[lptr] <= '9') {
  437.     /* number handling */
  438.  
  439.     punct = 3;
  440.     if (three[0] < 3200)
  441.         three[0] = three[0] * 10 + inbuf[lptr] - '0';
  442.     lptr += 1;
  443.     }
  444.     if (punct == 3 && (inbuf[lptr] != '.' &&
  445.                inbuf[lptr] != ',' && inbuf[lptr] != '?' &&
  446.                inbuf[lptr] != ' '))
  447.     punct = 6;
  448.     if (punct == 3 || punct == 6)
  449.     return (0);
  450.     do {
  451.     if (!((inbuf[lptr] >= 'a' && inbuf[lptr] <= 'z') ||
  452.           (inbuf[lptr] >= 'A' && inbuf[lptr] <= 'Z'))) {
  453.         lptr += 1;
  454.         punct = 4;
  455.         return (0);
  456.         /* the actual letter packing is done here  */
  457.  
  458.     }
  459.     kchar = inbuf[lptr];
  460.     if (kchar >= 'a' && kchar <= 'z')
  461.         kchar -= ' ';
  462.     if (wpnt < 4)
  463.         three[wpnt - 1] = three[wpnt - 1] +
  464.                                 (kchar - '@') * pow32[3 - plcpnt];
  465.     plcpnt += 1;
  466.     if (plcpnt >= 4) {
  467.         wpnt += 1;
  468.         plcpnt = 1;
  469.     }
  470.     lptr += 1;
  471.     m = inbuf[lptr];
  472.     if (m == ' ' || m == ',' || m == '.' || m == '?') {
  473.         if (three[0] != 20741 || three[1] != 14336 ||
  474.         three[2] != 0)
  475.         return (0);
  476.         punct = 1;
  477.         return (0);
  478.     }
  479.     }
  480.     while (m < '0' || m > '9');
  481.     punct = 5;
  482.     return (0);
  483. }
  484.  
  485.  
  486. find(m)
  487.     int             m;
  488. {
  489.     /*
  490.      * this routine searches a vocabulary to find a word. index, on output,
  491.      * gives the position of the word in the list. synonyms do not increment
  492.      * the counter, so index*3-2 is **not** the actual pointer to the word in
  493.      * the list 
  494.      */
  495.  
  496.     int             i, t, k, type;
  497.  
  498.     for (i = 0; i < 5; i++)
  499.     index[i] = 0;
  500.     t = 0;
  501.     indx = 0;
  502.  
  503.     for (i = 1; i <= m * 3 - 2; i += 3) {
  504.  
  505.     if (vocab[i] > 0)
  506.         indx += 1;
  507.     if (abs(vocab[i]) != three[0])
  508.         continue;
  509.     if (vocab[i + 1] != three[1])
  510.         continue;
  511.     if (vocab[i + 2] == three[2]) {
  512.         t = indx;
  513.         type = 1;
  514.         for (k = 1; k <= 4; k++)
  515.         if (indx >= typlst[k - 1])
  516.             type = type + 1;
  517.         index[type - 1] = indx;
  518.     }
  519.     }
  520.     indx = t;
  521. }
  522.  
  523. lbit(arg, pow)
  524.     int             arg, pow;
  525. {
  526.     return ((arg & (1 << pow)) != 0);
  527. }
  528.  
  529. parse()
  530. {
  531.     /*
  532.      * subroutine parse this mess deciphers the various direct and indirect
  533.      * (i.e. second, usually, but in 'give frog cup' the frog is the i.o.)
  534.      * objects. it associates them with their respective adjectives (dobjs(i)
  535.      * and doadjs(i) correspond) butflg is set if the "all but" construct is
  536.      * encountered allflg is set if the "all" construct is enconntered the
  537.      * d.o. and i.o prepositions are put in prepdo and prepio 
  538.      */
  539.  
  540.     int             result, wptr, thevrb, vrbind, vdo, vio, vobj, i;
  541.     int             frstaj, frstnn, errno, tprp;
  542.     result = 0;
  543.     thevrb = wrdnum[0];
  544.     vrbind = thevrb - VRBMIN + 1;
  545.  
  546.     vdo = 0;
  547.     vio = 0;
  548.     vobj = 0;
  549.     if (thevrb < SHIT) {
  550.     vdo = vrbpdo[vrbind];
  551.     vio = vrbpio[vrbind];
  552.     vobj = vrbobj[vrbind];
  553.     }
  554.     butflg = 0;
  555.     allflg = 0;
  556.     numdo = 0;
  557.     prepdo = 0;
  558.     prepio = 0;
  559.     iobj = 0;
  560.     ioadj = 0;
  561.     for (i = 0; i < 12; i++) {
  562.     dobjs[i] = 0;
  563.     doadjs[i] = 0;
  564.     }
  565.     /* this block is a test for "sit down" or "get up" or "look up" etc */
  566.  
  567.     if (((lbit(vobj, 1) && wrdnum[1] == DOWN) ||
  568.      (lbit(vobj, 2) && wrdnum[1] == UP)) && wrdtyp[2] == -1) {
  569.     prepdo = wrdnum[1];
  570.     result = 1;
  571.     goto finalout;
  572.     }
  573.     /* yell allows anything after it */
  574.  
  575.     if (thevrb == YELL)
  576.     goto testout;
  577.     wptr = 1;
  578.     frstaj = 0;
  579.     frstnn = 0;
  580.     /* a preposition immediately follows verb */
  581.  
  582.     if (wrdtyp[wptr] == 5) {
  583.     prepdo = wrdnum[wptr];
  584.     if (prepdo == BUT) {
  585.         errno = 21;
  586.         goto errorout;
  587.     }
  588.     if (!lbit(vdo, (prepdo - PRPMIN))) {
  589.         errno = 21;
  590.         goto errorout;
  591.     }
  592.     wptr += 1;
  593.     }
  594.     /*
  595.      * adjective follows verb *** special case of "terran" and "cygnan" as
  596.      * nouns 
  597.      */
  598.  
  599.     if (wrdtyp[wptr] == 3) {
  600.     if ((wrdnum[wptr] == TERRAN || wrdnum[wptr] == CYGNAN)
  601.         && wrdnum[0] == TRANSL)
  602.         wrdtyp[wptr] = 4;
  603.     else {
  604.         frstaj = wrdnum[wptr];
  605.         doadjs[0] = frstaj;
  606.         wptr += 1;
  607.     }
  608.     }
  609.     /* this takes care of the case of a verb alone on a line */
  610.  
  611.     if (wrdtyp[wptr] != 4) {
  612.     if (wrdtyp[wptr] != -1) {
  613.         errno = 28;
  614.         goto errorout;
  615.     } else {
  616.         {
  617.         if (thevrb >= SHIT) {
  618.             result = 1;
  619.             goto finalout;
  620.         }
  621.         if (!lbit(vobj, 7)) {
  622.             result = 1;
  623.             goto finalout;
  624.         }
  625.         }
  626.         errno = 27;
  627.         goto errorout;
  628.     }
  629.     }
  630.     frstnn = wrdnum[wptr];
  631.     /* look at first set of objects (not always d.o.) */
  632.  
  633.     dobjs[0] = frstnn;
  634.     numdo += 1;
  635.     if (numdo == 9) {
  636.     errno = 25;
  637.     goto errorout;
  638.     }
  639.     wptr += 1;
  640.  
  641.  
  642.     /* the following takes care of multiple objects */
  643.  
  644.     if (frstnn == ALL) {
  645.     if (!lbit(vobj, 5)) {
  646.         errno = 22;
  647.         goto errorout;
  648.     }
  649.     if (frstaj != 0) {
  650.         errno = 26;
  651.         goto errorout;
  652.     }
  653.     allflg = 1;
  654.     if (wrdnum[wptr] == BUT) {
  655.         butflg = 1;
  656.         /* check for adjective before noun */
  657.  
  658.         if (!(wrdtyp[wptr + 1] == 4 || (wrdtyp[wptr + 1] == 3
  659.                         && wrdtyp[wptr + 2] == 4))) {
  660.         errno = 23;
  661.         goto errorout;
  662.         }
  663.         wptr += 1;
  664.     }
  665.     }
  666.     if (butflg || (wrdtyp[wptr] == -2)) {
  667.     if (!lbit(vobj, 5)) {
  668.         errno = 22;
  669.         goto errorout;
  670.     }
  671.     mulobj(&wptr);
  672.     if (numdo > 9) {
  673.         errno = 25;
  674.         goto errorout;
  675.     }
  676.     }
  677.     /********** end multiple obj processor  */
  678.  
  679.  
  680.     if (wrdtyp[wptr] == -1)
  681.     goto testout;
  682.  
  683.     /* if the verb is "is" we may have a final adjective  */
  684.  
  685.     if (thevrb == IS && wrdtyp[wptr] == 3) {
  686.     doadjs[1] = wrdnum[wptr];
  687.     if (wrdtyp[wptr + 1] == -1)
  688.         goto testout;
  689.     errno = 20;
  690.     goto errorout;
  691.     }
  692.     /*
  693.      * if the next word is a noun or adjective, and verb is not "is" we have
  694.      * a non-prep indirect object such as the frog in "give frog water" 
  695.      */
  696.  
  697.     if (wrdtyp[wptr] == 4 || (wrdtyp[wptr] == 3 && wrdtyp[wptr + 1]
  698.                   == 4)) {
  699.     if (numdo > 1 || prepdo != 0) {
  700.         errno = 22;
  701.         goto errorout;
  702.     }
  703.     if (!lbit(vobj, 3)) {
  704.         errno = 24;
  705.         goto errorout;
  706.     }
  707.     prepio = TO;
  708.     ioadj = frstaj;
  709.     iobj = frstnn;
  710.     doadjs[0] = 0;
  711.     if (wrdtyp[wptr] == 3) {
  712.         doadjs[0] = wrdnum[wptr];
  713.         wptr += 1;
  714.     }
  715.     dobjs[0] = wrdnum[wptr];
  716.     numdo = 1;
  717.     wptr += 1;
  718.     /****** repeat the multiple obj processor */
  719.  
  720.     if (dobjs[0] == ALL) {
  721.         if (!lbit(vobj, 5)) {
  722.         errno = 22;
  723.         goto errorout;
  724.         }
  725.         if (doadjs[0] != 0) {
  726.         errno = 26;
  727.         goto errorout;
  728.         }
  729.         allflg = 1;
  730.         if (wrdtyp[wptr] == 5 && wrdnum[wptr] == BUT) {
  731.         butflg = 1;
  732.         if (!(wrdtyp[wptr + 1] == 4 || (wrdtyp[wptr + 1] == 3
  733.                         && wrdtyp[wptr + 2] == 4))) {
  734.             errno = 23;
  735.             goto errorout;
  736.         }
  737.         }
  738.     }
  739.     if (butflg || wrdtyp[wptr] == -2) {
  740.         if (!lbit(vobj, 5)) {
  741.         errno = 22;
  742.         goto errorout;
  743.         }
  744.         mulobj(&wptr);
  745.         if (numdo > 9) {
  746.         errno = 25;
  747.         goto errorout;
  748.         }
  749.     }
  750.     /***** end multiple object processor */
  751.  
  752.     if (wrdtyp[wptr] != -1) {
  753.         errno = 20;
  754.         goto errorout;
  755.     }
  756.     goto testout;
  757.     }
  758.     /* the only thing left that is legal is a perpositional construct */
  759.  
  760.     if (wrdtyp[wptr] != 5 || wrdnum[wptr] == BUT || (
  761.             wrdtyp[wptr + 1] == 5 && wrdnum[wptr + 1] == BUT)) {
  762.     errno = 20;
  763.     goto errorout;
  764.     }
  765.     tprp = wrdnum[wptr];
  766.     wptr += 1;
  767.     /*
  768.      * check for end of line or two preps in a row (e.g. fill the bottle up
  769.      * with water) 
  770.      */
  771.  
  772.     if (wrdtyp[wptr] == -1 || wrdtyp[wptr] == 5) {
  773.     if (prepdo != 0 || (!lbit(vdo, (tprp - PRPMIN)))
  774.         || (!lbit(vobj, 0))) {
  775.         errno = 20;
  776.         goto errorout;
  777.     }
  778.     prepdo = tprp;
  779.     if (wrdtyp[wptr] == -1)
  780.         goto testout;
  781.     wptr += 1;
  782.     }
  783.     if (!lbit(vio, (wrdnum[wptr - 1] - PRPMIN))) {
  784.     errno = 20;
  785.     goto errorout;
  786.     }
  787.     prepio = wrdnum[wptr - 1];
  788.     if (wrdtyp[wptr] == 3) {
  789.     ioadj = wrdnum[wptr];
  790.     wptr += 1;
  791.     }
  792.     if (wrdtyp[wptr] != 4) {
  793.     errno = 20;
  794.     goto errorout;
  795.     }
  796.     iobj = wrdnum[wptr];
  797.     wptr += 1;
  798.     if (wrdtyp[wptr] != -1) {
  799.     errno = 20;
  800.     goto errorout;
  801.     }
  802. testout:
  803.     if ((dobjs[0] == 0 && lbit(vobj, 7)) || (iobj == 0 &&
  804.                          lbit(vobj, 6))) {
  805.     errno = 20;
  806.     goto errorout;
  807.     }
  808.     if (!lbit(vobj, 4) && dobjs[0] != 0 && prepdo == 0) {
  809.     errno = 19;
  810.     goto errorout;
  811.     }
  812.     result = 1;
  813. finalout:
  814.  
  815.     if (wrdnum[0] == AGAIN) {
  816.     for (i = 0; i < 12; i++) {
  817.         doadjs[i] = zadjs[i];
  818.         dobjs[i] = zobjs[i];
  819.     }
  820.     ioadj = ziadj;
  821.     iobj = ziobj;
  822.     prepdo = zpdo;
  823.     prepio = zpio;
  824.     actor = zactor;
  825.     adverb = zadvrb;
  826.     wrdnum[0] = zverb;
  827.     numdo = znumb;
  828.     allflg = zall;
  829.     butflg = zbut;
  830.     } else {
  831.     for (i = 0; i < 12; i++) {
  832.         zadjs[i] = doadjs[i];
  833.         zobjs[i] = dobjs[i];
  834.     }
  835.     ziadj = ioadj;
  836.     ziobj = iobj;
  837.     zpdo = prepdo;
  838.     zpio = prepio;
  839.     zactor = actor;
  840.     zadvrb = adverb;
  841.     zverb = wrdnum[0];
  842.     zall = allflg;
  843.     zbut = butflg;
  844.     }
  845.     return (result);
  846. errorout:
  847.     carerr(0, errno);
  848.     return (result);
  849. }
  850.  
  851. mulobj(wptr)
  852.     int            *wptr;
  853. {
  854.     /****   multiple opject subroutine from "parse" */
  855.  
  856.     while (1) {
  857.     if (wrdtyp[*wptr] == 3) {
  858.         doadjs[numdo] = wrdnum[*wptr];
  859.         *wptr += 1;
  860.     }
  861.     if (wrdtyp[*wptr] == 4) {
  862.         numdo += 1;
  863.         if (numdo > 10)
  864.         return (1);
  865.         dobjs[numdo - 1] = wrdnum[*wptr];
  866.         *wptr += 1;
  867.         if (wrdtyp[*wptr] != -2)
  868.         return (1);
  869.     }
  870.     *wptr += 1;
  871.     }
  872. }
  873.